<template>
  <div class="pay-success-page">
    <van-nav-bar
        title="支付成功"
        left-arrow
        @click-left="handleGoBack"
    />
    <div class="success-container">
      <!-- 成功图标和文字 -->
      <van-icon
          name="success"
          class="success-icon"
          size="80"
          color="#1989fa"
      />
      <div class="success-text">支付成功</div>
      <div class="success-desc">
        您已成功购买商品，请尽快与卖家联系确认交易细节
      </div>
      <!-- 订单号 -->
      <div class="order-number">
        订单号: {{ orderNumber }}
      </div>

      <!-- 购买商品信息 -->
      <div class="goods-info-card">
        <h3 class="card-title">购买商品</h3>
        <div class="goods-item">
          <img
              class="goods-img"
              src="https://img.yzcdn.cn/vant/cat.jpeg"
              alt="商品图片"
          />
          <div class="goods-desc">
            <div class="goods-name">{{ itemTitle }}</div>
            <div class="goods-price">¥{{ itemPrice }}</div>
          </div>
        </div>
      </div>

      <!-- 支付信息 -->
      <div class="pay-info-card">
        <h3 class="card-title">支付信息</h3>
        <div class="info-item">
          <span class="info-label">支付方式</span>
          <span class="info-value">{{ payMethod }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">支付时间</span>
          <span class="info-value">{{ payTime }}</span>
        </div>
        <div class="info-item">
          <span class="info-label">订单编号</span>
          <span class="info-value">{{ orderNumber }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { showToast } from "vant";

const route = useRoute();
const router = useRouter();

// 接收路由参数
const orderNumber = ref(route.query.orderNumber as string);
const itemTitle = ref(route.query.itemTitle as string);
const itemPrice = ref(route.query.itemPrice as string);
const payMethod = ref(route.query.payMethod as string);
const payTime = ref(route.query.payTime as string);

// 返回上一页
const handleGoBack = () => {
  router.back();
};
onMounted(() =>{
  console.log("zhifuchenggong")
})
</script>

<style scoped>
.pay-success-page {
  background-color: #f5f5f5;
  min-height: 100vh;
  padding-bottom: 60px;
}

.success-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 30px;
}

.success-icon {
  margin-bottom: 16px;
}

.success-text {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin-bottom: 8px;
}

.success-desc {
  font-size: 14px;
  color: #666;
  margin-bottom: 24px;
  text-align: center;
  width: 80%;
}

.order-number {
  background-color: #f0f0f0;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 14px;
  color: #666;
  margin-bottom: 24px;
}

.goods-info-card,
.pay-info-card {
  background-color: #fff;
  width: 90%;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}

.goods-item {
  display: flex;
  align-items: center;
}

.goods-img {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
  margin-right: 12px;
}

.goods-desc {
  flex: 1;
}

.goods-name {
  font-size: 15px;
  color: #333;
  margin-bottom: 4px;
}

.goods-price {
  font-size: 14px;
  color: #ee0a24;
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
}

.info-item:last-child {
  margin-bottom: 0;
}

.info-label {
  color: #666;
}

.info-value {
  color: #333;
}
</style>